<?php
/**
 * Created by PhpStorm.
 * User: 1
 * Date: 2017-02-10
 * Time: 17:03
 */

namespace app\src\jobs;


use think\queue\Job;

class Hello
{
    public function fire(Job $job, $data){

        //....这里执行具体的任务
        echo $job->attempts()." times :  hello world\n";

        if ($job->attempts() > 3) {
            //通过这个方法可以检查这个任务已经重试了几次了
            $job->delete();
            echo "complete\n";
            return ;
        }

        $job->release(3);
    }

    public function failed($data){

        // ...任务达到最大重试次数后，失败了
        echo "failed";
    }

}